package view;

import java.awt.Color;
import java.awt.Dimension;
import java.awt.Toolkit;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;

import javax.swing.ImageIcon;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTabbedPane;
import javax.swing.JTable;

import controller.Zoogdiercontroller;
import TabelModels.ApenTabelModel;
import TabelModels.TijgerTabelModel;

public class Tijger_all_view extends JFrame{
	
	private static Tijger_all_view instance;
	private JPanel panel1 = new JPanel();
	private JTabbedPane tabPane = new JTabbedPane();
	

	public JTable tabel = new JTable();
	public JTable tabel2 = new JTable();
	private JPanel tabelApen = new JPanel();
	private JPanel tabelApenVrouw = new JPanel();
	
	Zoogdiercontroller zc = new Zoogdiercontroller();

	public static Tijger_all_view getInstance() {
		if (instance == null) {
			instance = new Tijger_all_view();
		}
		instance.setVisible(true);
		return instance;
	}

	private Tijger_all_view() {
		// #frame
		setSize(500, 400);
		setTitle("Tijger");

		Dimension dim = Toolkit.getDefaultToolkit().getScreenSize();
		this.setLocation(dim.width / 2 - this.getSize().width / 2, dim.height
				/ 2 - this.getSize().height / 2);

		// #panel1
		panel1.setVisible(true);
		panel1.setLayout(null);
		panel1.setSize(400, 400);
		panel1.setBackground(Color.white);

		// #tabb1
		// #tabel
		tabel = new JTable(new TijgerTabelModel("Man"));
		tabel2 = new JTable(new TijgerTabelModel("Vrouw"));
		
		
		JScrollPane scroll2 = new JScrollPane(tabel2);
		scroll2.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
		scroll2.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
		scroll2.setBounds(0, 0, tabelApenVrouw.getWidth(),
				tabelApenVrouw.getHeight());
		scroll2.setVisible(true);
		tabel2.setPreferredScrollableViewportSize(new Dimension(467, getHeight()));

		tabelApenVrouw.add(scroll2);
		
		JScrollPane scroll = new JScrollPane(tabel);
		scroll.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
		scroll.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
		scroll.setBounds(0, 0, tabelApen.getWidth(), tabelApen.getHeight());
		scroll.setVisible(true);
		tabel.setPreferredScrollableViewportSize(new Dimension(467, getHeight()));

		tabelApen.add(scroll);

		JPanel jp1 = new JPanel();
		jp1.setVisible(true);
		tabPane.setVisible(true);

		ImageIcon tab1Icon = new ImageIcon(this.getClass().getResource(
				"/img/vrouw.png"));

		JLabel label1 = new JLabel();
		label1.setText("This is Tab 1");

		jp1.add(tabelApenVrouw);

		tabPane.addTab("Vrouw", tab1Icon, jp1);

		add(tabPane);

		// #tabb2
		JPanel jp2 = new JPanel();
		jp2.setVisible(true);

		ImageIcon tab2Icon = new ImageIcon(this.getClass().getResource(
				"/img/man.png"));

		JLabel label2 = new JLabel();
		label2.setText("This is a Second label");
		jp2.add(tabelApen);

		tabPane.addTab("Man", tab2Icon, jp2);
		
		tabel.addMouseListener(new MouseAdapter() {
			public void mouseClicked(MouseEvent e) {
				if (e.getClickCount() == 2) {
					
					zc.tijger();
				}
			}
		});
		
		tabel2.addMouseListener(new MouseAdapter() {
			public void mouseClicked(MouseEvent e) {
				if (e.getClickCount() == 2) {
					
					zc.tijger2();
				}
			}
		});
	}
}
